# -*- coding: utf-8 -*-
from datetime import timedelta

from jms_hi.ods.tms.yl_tmsnew_time_effective_hi import jms_ods__yl_tmsnew_time_effective_hi

from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

jms_dim__dim_tmsnew_time_effective_base_hi = SparkSqlOperator(
    task_id='jms_dim__dim_tmsnew_time_effective_base_hi',
    email={'rabie.zhuang@jtexpress.com','yl_bigdata@yl-scm.com'},
    master='yarn',
    name='jms_dim__dim_tmsnew_time_effective_base_hi_{{ execution_date | cst_hour }}',
    sql='jms_hi/dim/dim_tmsnew_time_effective_base_hi/execute.sql',
    pool_slots=2,
    driver_cores=2 , 
    driver_memory='2G' , 
    executor_cores=2 , 
    executor_memory='1G' , 
    num_executors=2 , 
    depends_on_past=True,
    conf={'spark.dynamicAllocation.enabled'                  : 'true',
          'spark.shuffle.service.enabled'                    : 'true',
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 30,
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',
        'spark.executor.memoryOverhead'             : '2G' , 
          'spark.default.parallelism'                        : '240',
          'spark.speculation'                                : 'true',
          },
    hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode'        : 'nonstrict',
              'hive.exec.max.dynamic.partitions'        : 3000,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 3000,  # 最大分区
              },
    yarn_queue='default',
    execution_timeout=timedelta(minutes=30),
    retries=2,
)

jms_dim__dim_tmsnew_time_effective_base_hi << [
    jms_ods__yl_tmsnew_time_effective_hi,

]
